//字符串拼接 + 模拟 + 排序
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
string a[21];
bool cmp(string s1,string s2)
{
    return s1 + s2 > s2 + s1;
}
int main()
{
    string str3;
    int n;
    cin >> n;
    for(int i = 1 ; i <= n; i++) cin >> a[i];
    sort(a + 1 , a + n + 1 , cmp);
    for(int i = 1; i <= n; i++)
    str3 += a[i];
    cout << str3 <<endl;
    return 0;
}